<script type="text/javascript"><!--//--><![CDATA[//><!--

    $(document).ready(function() {
        // Setup Form
		$('#form_master').setupForm([
            { name: 'no_po', type: 'text', size: 'long', maxlength: 100, noempty:true, readonly:true },
			{ name: 'kd_vendor', type: 'lov', size: 'short',
				onClearButton:function(){
					$(this).setval(''); 
					$('#nama_vendor').setval(''); 
					var rows = $('#dtl_sample2').datagrid('getRows');
					for (var i = rows.length - 1; i >= 0; i--) {
						$('#dtl_sample2').datagrid('deleteRow', i);
					};
				},
				onActionButton:function(){ 
					LOVVendor({ onSelect:function(row){ 
						$('#kd_vendor').setval(row.supplier_kode); 
						$('#nama_vendor').setval(row.supplier_nama); 
					} }); 
				}
			},
			{ name: 'nama_vendor', type: 'text', size: '24', readonly:true },
			{ name: 'tgl_order', type: 'date' },
			{ name: 'tgl_terima', type: 'date' },
			{ name: 'salesman', type: 'text' },
			{ name: 'pembuat_po', type: 'text' },
			{ name: 'status', type: 'text' }
			
        ], <?php echo json_encode($data); ?>);
        
		
        <?php if($mode=="edit"){ ?>
        	$('#no_po').readonly();
        <?php } ?>
		
		// Set Action Button
		var buttons = [{ label: 'Save', icon: 'save', onclick: function() { 
							$('#form_master').submitForm(	'/'+controller+'/ajax_post', 
							{ detail:[	{ table: 'dtl_sample2', field:['kd_barang','qty_order','no_po']}																	], 
							onComplete : function(data){ eval('oData = '+data); loadPage('/'+controller+'/edit/?no_po='+(oData.genid!='' ? oData.genid : $('#no_po').getval())); }
															} 
														); 
						}},
					   { label: 'Close', icon: 'cancel', onclick: function() { loadPage('/'+controller+'/Index'); } }];
		setAction(buttons);
		
		// Create Tab
		$('#tt').tabs({ border:false });  
		
		// Focus at First Object
		$('#form_master').focusFirst();
    });
//--><!]]></script>

<div id="form_master_message" style="display:none;"></div>
<table class="tb_form" style="display:none;" cellpadding="0" cellspacing="0">

<tr>
    <td class="label">No PO</td>
    <td><input id="no_po" /></td>
    <td width="50"></td>
    <td class="label">Tanggal PO</td>
    <td><input id="tgl_order" /></td>
</tr>
<tr>
	<td class="label">Supplier</td>
    <td><input id="kd_vendor" /><input id="nama_vendor" /></td>
    <td></td>
    <td class="label">Terima Sebelum Tanggal</td>
    <td><input id="tgl_terima" /></td>
</tr>
<tr>
	<td class="label">Salesman</td>
    <td><input id="salesman" /></td>
    <td></td>
    <td class="label">Status</td>
    <td>
    	<select name="status" id="status" class="textfield medium">
    		<option value="Order">Order</option>
    		<option value="Receive">Receive</option>
    	</select>

    </td>
</tr>
<tr>
	<td class="label">Pembuat PO</td>
    <td><input id="pembuat_po" /></td>
    <td></td>
    <td></td>
    <td></td>
</tr>
</table>
<div id="tt" class="easyui-tabs" style="min-height:400px;">  
	
    
    <div title="Detail Barang" style="overflow:auto;padding:10px;">  
    	<?php require_once('formdtl_sample2.php'); ?>
    </div>
    
</div>